<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            let arr = [1, 2, 3];
            console.log(arr.pop()); // 3
            console.log(arr); // [1,2]

            Array.prototype.myPop = function () {
                let result = this[this.length - 1];
                this.length = this.length - 1;
                return result;
            };
            console.log(arr.myPop()); // 3
            console.log(arr); // [1,2]
        </script>
    </body>
</html>
